cnt = 0
for i in range(1, 2021):
    s = str(i)
    for c in s:
        if c == '2':
            cnt += 1
print(cnt)